package com.atguigu.spring6.xmltx.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CheckoutServiceImpl implements CheckoutService {

    @Autowired
    private BookService bookService;

    /**
     *
     * @param bookIds
     * @param userId
     */

    //买多本书的方法
    @Transactional
    @Override
    public void checkout(Integer[] bookIds, Integer userId) throws InterruptedException {
        for(Integer bookId : bookIds){
            // 调用买书的service方法
            bookService.buyBook(bookId,userId);
        }
    }
}
